/*
 * Copyright (C) 2005-2006 Dmitri Maximovich <maxim@md.pp.ru>
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 *
 */

const ccVersion = "@version";

var U = {
  update: function() {
    const prevVersion = P.getString("version", null);
    if (ccVersion == prevVersion) {
      return;
    }
    CC.log("Updated from version: "+prevVersion+" to "+ccVersion);
    P.setString("version", ccVersion);
    U.ping(prevVersion);
  },

  ping: function(prevVersion) {
    try {
	  var request = new XMLHttpRequest();
	  // encodeURIComponent(window.navigator.appVersion)
	  request.open("GET", "http://www.md.pp.ru/mozilla/cc/ping.jsp?fromVersion="+prevVersion+"&toVersion="+ccVersion, true);
	  request.send(null);
    }
	catch (e) {
	  CC.log("Error in ping(): "+e);
	}
  }
 
}

// run
window.addEventListener("load", function() {U.update();}, false);
